<template>
    <div>
        <el-form :model="intoForm"  label-width="180px" ref="intoFormRef" :rules="intoFormRules">
            <el-form-item>
                <el-radio-group v-model="intoForm.type">
                    <el-radio :label="2">公众号</el-radio>
                    <el-radio :label="1">小程序</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="APPID：" prop="appid" v-if="intoForm.type==1" >
                <el-input v-model="intoForm.appid"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="confirmOpen">开通支付</el-button>
                <el-button>取消</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
export default {
    props: {
        id: Number
    },
    data() {
        return {
            intoForm: {
                type:2
            },
            intoFormRules: {
                appid: [
                    { required: true, message: '请输入appid', trigger: 'blur' },
                ]
            }
        }
    },
    created() {

    },
    methods: {
        confirmOpen() {
            let _this=this;
            this.$refs.intoFormRef.validate((valid) => {
                if (valid) {
                    this.$axios({
                        url: '/admin/channel/other',
                        data: {
                            type: 1,
                            userID: _this.id,
                            genre: 5,
                            APPID:_this.intoForm.type==1?_this.intoForm.appid:''
                        },
                        success(res) {
                            if(res.data.code==200){
                                _this.$message({
                                    message:res.data.msg,
                                    type:'success'
                                });
                            }else{
                                _this.$message.error(res.data.msg)
                            }
                        }
                    });
                }
            })
        }
    }
}
</script>
<style scoped>
.el-input {
    width: 200px;
}
</style>